package com.epfly.promo.activity.dao;

import com.epfly.promo.activity.entity.ActivityDinnerBoundEntity;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.additional.insert.InsertListMapper;
import tk.mybatis.mapper.common.BaseMapper;

@Mapper
public interface ActivityDinnerBoundMapper extends BaseMapper<ActivityDinnerBoundEntity>, InsertListMapper<ActivityDinnerBoundEntity> {


    @Delete(value = "delete from tbl_activity_dinner_bound where activity_id = #{activityId} and del_flag = 0")
    int deleteByActivityId(@Param(value = "activityId") Long activityId);

    @ResultMap(value = "activityDinnerBoundMapperBaseResultMap")
    @Select(value = "select dinner_type, amount_bound, count_bound, is_active from tbl_activity_dinner_bound where activity_id = #{activityId} and del_flag = 0")
    java.util.List<ActivityDinnerBoundEntity> findByActivityId(@Param(value = "activityId") Long activityId);

    @Select(value = "select activity_id, dinner_type, amount_bound, count_bound, is_active from tbl_activity_dinner_bound " +
            " where activity_id = #{activityId} and dinner_type = #{dinnerType} and is_active = #{isActive} and del_flag = 0 ")
    ActivityDinnerBoundEntity findByActivityIdAndDinnerTypeAndIsActive(@Param(value = "activityId") Long activityId, @Param(value = "dinnerType") Byte dinnerType, @Param(value = "isActive") Byte isActive);
}
